package com.xiaobai.redisContact.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RequiredArgsConstructor
@RequestMapping("queue")
@Tag(name = "消息队列")
public class QueueController {
    @Resource
    private final RedisTemplate redisTemplate;
    @GetMapping
    @Operation(summary = "发送消息")
    public Boolean send(String message,
                        Integer time) {
        redisTemplate.opsForValue().set("消息", message, time, TimeUnit.SECONDS);
        return true;
    }

}
